package com.ikunikun.controller.user;

import com.ikunikun.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController("userShopController")
@RequestMapping("/user/shop")
@Api(tags = "用户端店铺信息")
public class ShopController {
	private final String KEY = "SHOP_STATUS";
	@Resource
	private RedisTemplate redisTemplate;

	/**
	 * 获取店铺营业状态
	 * @return
	 */
	@GetMapping("/status")
	@ApiOperation("获取店铺营业状态")
	public Result getStatus(){
		Integer status = (Integer) redisTemplate.opsForValue().get(KEY);
		log.info("获取到店铺的营业转态为：{}", status == 1 ? "店铺营业中" : "店铺暂停营业");
		return Result.success(status);
	}
}
